package cn.com.shopec.erp.stock.excel.impl;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;

import cn.com.shopec.erp.common.excel.ExcelBaseExport;
import cn.com.shopec.erp.common.utils.DateUtil;
import cn.com.shopec.erp.stock.vo.StockOutVo;

public class StockOutExcelExport extends ExcelBaseExport {

	public StockOutExcelExport(List<StockOutVo> data, String fileName,
			HttpServletResponse response) {
		super(data, fileName, response);
	}

	@Override
	protected Row setColumnMapping(Object data, Row row) {
		StockOutVo stockOutVo = (StockOutVo) data;
		int cellIndex = 0;
		Cell cell = row.createCell(cellIndex++);
		cell.setCellValue(stockOutVo.getStockOutNo());

		cell = row.createCell(cellIndex++);
		cell.setCellValue(getStockOutTypeName(stockOutVo.getStockOutType()));
		
		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockOutVo.getReceiverName());

		cell = row.createCell(cellIndex++);
		cell.setCellValue(DateUtil.formatTimesTampDate(stockOutVo.getCreateTime()));
		
		cell = row.createCell(cellIndex++);
		cell.setCellValue(DateUtil.formatTimesTampDate(stockOutVo.getUpdateTime()));
		
		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockOutVo.getUpdater());
		
		cell = row.createCell(cellIndex++);
		cell.setCellValue(stockOutVo.getStockOutState()==1?"已出库":"未出库");
		
		return row;
	}

	@Override
	protected List<String> setExcelTitleValue() {
		List<String> title = new ArrayList<String>();
		title.add("单号");
		title.add("出库类型");
		title.add("收货人");
		title.add("创建时间");
		title.add("出库时间");
		title.add("出库人员");
		title.add("出库状态");
		return title;
	}
	
	private String getStockOutTypeName(int type){
		String typename = "";
        switch(type){
        	case -1 : typename="包裹销售出库"; break;
        	case -2 : typename="采购退换货出库"; break; 
        	case -3 : typename="次品退换货出库"; break;  
        	case -4 : typename="订单退换货出库"; break;
            default : break;
        }
        return typename; 
	}

}
